#!/usr/bin/env python

import sys, os

pacman_pkgs = os.popen('pacman -Q').read().strip().split('\n')
pacman_pkgs = [ pkg.split()[0].strip() for pkg in pacman_pkgs ]
pacman_pkg_num = len(pacman_pkgs)
flatpak_enable = 'flatpak' in pacman_pkgs

if flatpak_enable:
    flatpak_pkg_num = int(os.popen('flatpak list | wc -l').read().strip())
else:
    flatpak_pkg_num = 0

if flatpak_pkg_num > 0:
    res = f"{pacman_pkg_num}(pacman) {flatpak_pkg_num}(flatpak)"
else:
    res = f"{pacman_pkg_num}(pacman)"

print(res, end='')
